//
//  BalanceCashViewController.m
//  BusinessApp
//
//  Created by macox on 16/10/6.
//  Copyright © 2016年 macox. All rights reserved.
//

#import "BalanceCashViewController.h"
#import "DayAccountViewController.h"
#import "DepositViewController.h"
#import "MyWalleModel.h"
#import "AddaBankCardViewController.h"
#import "RuZhuViewController.h"
@interface BalanceCashViewController ()
@property (nonatomic , strong) NSString *brank;
@property (nonatomic , strong) NSString *AccountMoneyString;
@property (nonatomic , strong) NSString *ShopIsDaiLi;
@end

@implementation BalanceCashViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"余额提现";
    UIImage *classBackImage = [UIImage imageNamed:@"zuojiantou@3x-1"];
    classBackImage = [classBackImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:classBackImage style:UIBarButtonItemStylePlain target:self action:@selector(classBackAction)];
    
    
    
    UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:@"流水账" style:UIBarButtonItemStylePlain target:self action:@selector(liushuizhangAction)];
    self.navigationItem.rightBarButtonItem = rightBarItem;
    self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
    // Do any additional setup after loading the view from its nib.
}
-(void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [self requestData];
}
- (void)requestData
{
    //    _goodDataStatusArr = [NSMutableArray array];
    NSDictionary *param = @{@"ShouJiHao":GETPHONE,@"Duuid":GETUUID,@"Token":GETTOKEN};
    [GDJHttpTool get:MineInfo params:param success:^(id responseObj) {
        NSLog(@"%@", responseObj);
        NSLog(@"%@", param);
        if ([[responseObj objectForKey:@"Err"] intValue]) {
            
        }else{
            
            NSDictionary *dataDic = [responseObj objectForKey:@"MineInfo"];
            
            MyWalleModel *model = [MyWalleModel mj_objectWithKeyValues:dataDic];
            _AccountMoney.text = [NSString stringWithFormat:@"%@元",model.ShopYuE];
            _AccountMoneyString = [NSString stringWithFormat:@"%@",model.ShopYuE];
            _brank = [NSString stringWithFormat:@"%@",model.HasBindBankCard];
            _ShopIsDaiLi = model.ShopIsDaiLi;
            NSLog(@"=========----%@",_brank);

        }
    } failure:^(NSError *error) {
        NSLog(@"%@",error);
    }];
}
#pragma mark -- 提现
- (IBAction)tixianAction:(UIButton *)sender {
    NSLog(@"提现");
    NSLog(@"======%@",_brank);
    if ([_brank isEqualToString:@"0"]) {
        [SVProgressHUD showErrorWithStatus:@"请先添加收款账户" ];
    } else{
        DepositViewController *depositVC = [[DepositViewController alloc]init];
        depositVC.AccountMoeny =  _AccountMoneyString;
        depositVC.ShopIsDaiLi = _ShopIsDaiLi;
        self.hidesBottomBarWhenPushed=YES;
        [self.navigationController pushViewController:depositVC animated:YES];
    }
   
//        RuZhuViewController *ruzhuVC = [[RuZhuViewController alloc]init];
//        self.hidesBottomBarWhenPushed=YES;
//        [self.navigationController pushViewController:ruzhuVC animated:YES];
//        self.hidesBottomBarWhenPushed=NO;
}
#pragma mark -- 添加
- (IBAction)addBtnAction:(UIButton *)sender {
        NSLog(@"添加");
    AddaBankCardViewController *addBankVC = [[AddaBankCardViewController alloc]init];
     self.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:addBankVC animated:YES];
 
}
#pragma mark -- 返回
- (void)classBackAction{
    
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark -- 流水账
- (void)liushuizhangAction{
    DayAccountViewController  *datAccountVC = [[DayAccountViewController alloc]init];
    self.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:datAccountVC animated:YES];

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
